uses graph,crt,constant,utils,draw,cpu;
var i,x: integer;
    Power: boolean;
    ch: char;
    st: string;
    NewTime, OldTime,tiks: longint;
begin
  NewTime:=0;
  OldTime:=0;
  tiks:=meml[$40:$6c];
  Initialize;
  meml[$40:$6c]:=tiks;
  DrawMashine;
  Power := False;
  selectedItemIdx:=2;
  repeat
   SelectItem(selectedItemIdx);
   repeat
    OutCurrentTime(NewTime,OldTime);
    Interpretator;
   until KeyPressed;
   Ch := ReadChar;
   case Ch of
    CEsc: State:=State_Default;
    CExit: Power := True;
    CTab:  begin
            UnSelectItem(selectedItemIdx);
            if selectedItemIdx = LimitDrawMemory then selectedItemIdx:=2
             else Inc(selectedItemIdx);
           end;
    CPlus: begin
            if (selectedItemIdx=12) xor (selectedItemIdx=13)
            then
               IncDecSS(selectedItemIdx,true)
            else
               IncDec(selectedItemIdx,true);
           end;
    CMinus:begin
            if (selectedItemIdx=12)xor (selectedItemIdx=13)
            then
              IncDecSS(selectedItemIdx,false)
            else
              IncDec(selectedItemIdx,false);
           end;
    CNewValue: NewValue;
    CF9: State := State_Demo;
    CF7: State := State_Step;
    CCtrlF9: State := State_Automat;
    else
     Beep;
   end;
  until Power;
  CloseGraph;
end.
